www.gusucode.com > 24Beta 虚拟主机版 1.0.0 Beta源码程序 > 24Beta 虚拟主机版 1.0.0 Beta源码程序/24Beta-1.0.0-vhost/protected/controllers/DefaultController.php

    <?php

class DefaultController extends CController
{
	/**
	 * Declares class-based actions.
	 */
	public function actions()
	{
		return array(
			array(
            	'COutputCache + index',
            	'duration' => param('expireIndexPost'),
            ),
		);
	}

	/**
	 * This is the default 'index' action that is invoked
	 * when an action is not explicitly requested by users.
	 */
	public function actionIndex()
	{
		/*
    	 * 获取所有有效的文章分类
    	 */
        $categorys = Category::model()->getShowCategorys();
        
        /*
         * 获取最新的文章列表,文章数量以变量替换,换生成$pagination分布对象
         */
        $category_id = (int)trim($_GET['category']);
        $activePosts = Post::model()->getActivePosts(param('listPostsNums'), $category_id);
        
        /*
         * 获取访问量最高的新闻列表,条数以变量替换
         */
        $maxVisit = Post::model()->getTopVisit($category_id, null, param('topPostsNums'));
        
        /*
         * 获取评论数量量最多的新闻列表,条数以变量替换
         */
        $maxComment = Post::model()->getTopComment($category_id, null, param('topPostsNums'));
        
        /*
         * 获取编辑推荐的新闻列表,条数以变量替换
         */
        $editorRecommend = Post::model()->getEditorRecommend($category_id, null, param('editorRecommendNums'));
        
        /*
         * 获取热门文章
         */
        $hotPosts = Post::model()->getHotPosts(param('hotPostsNums'));
        
        /*
         * 获取编辑推荐的评论,条数以变量替换
         */
        $recommendComment = Comment::model()->getRecommendComment(param('recommendCommentNums'));
        
		$ads = Advertisement::model()->getAllAvlidTokenIsKey();
		$friendLinks = FriendLink::model()->getAllFriendLinks(FriendLink::YES);
        
		$data = array(
			'categorys'    => $categorys,
		    'hotPosts'     => $hotPosts,
		    'maxVisit'	   => $maxVisit,
		    'maxComment'   => $maxComment,
		    'editorRecommend' => $editorRecommend,
		    'recommendComment' => $recommendComment,
		    'ads' => $ads,
		    'friendLinks' => $friendLinks,
		);
		$data = array_merge($data, $activePosts);
		
		$this->render('/post/list', $data);
	}

	
}